#include <iostream>

void printNQueen(int n);
void dfs(int QueenX[101], int n, int count);
void outPrint(int QueenX[101], int n);
int abs(int a){
	if(a >= 0) return a;
	else return -a;
}

int main(){
	//get how many queens
	int n;
	std::cin >> n;

	//print the position
	printNQueen(n);
}
void printNQueen(int n){
	//init the QueenX
	int QueenX[101] = {0};
	dfs(QueenX, n, 0);
}

void dfs(int QueenX[101], int n, int count){
	//count is the number has been made
	if(count >= n){
		outPrint(QueenX, n);
		return;
	}

	int temp[101]; //init:all the site are available
	for(int i = 1; i <= n; i++){
		temp[i] = 1;
	}

	for(int i = 1; i <= count; i++){
		/* the following site is not available */
		temp[QueenX[i]] = 0; 
		if(QueenX[i] - abs(count + 1 - i) > 0) temp[QueenX[i]-abs(count + 1 - i)] = 0;
		if(QueenX[i] + abs(count + 1 - i) <= n) temp[QueenX[i]+abs(count + 1 - i)] = 0;
	}
	/* for every available site, the Queen seated here */
	for(int i = 1; i <= n; i++){
		if(temp[i] == 1){
			QueenX[count + 1] = i;
			dfs(QueenX, n, count + 1);
			QueenX[count + 1] = 0;
		}
	}
}

//output the answer of nQueen
void outPrint(int QueenX[101], int n){
	int temp[101] = {0};
	for(int i = 1; i <= n; i++){
		temp[QueenX[i]] = 1;
		for(int j = 1; j <= n; j++){
			std::cout << temp[j] << ' ';
		}
		std::cout << std::endl;
		temp[QueenX[i]] = 0;
	}
	std::cout << std::endl;
}
